package TestSportMeet;

import java.util.*;

public class TestSportMeet {
    public static void main(String[] args) {
        SportStudent stu1 = new SportStudent("张三");
        SportStudent stu2 = new SportStudent("老六");
        SportStudent stu3 = new SportStudent("李四");
        SportStudent stu4 = new SportStudent("王五");



//        SportStudent[] run = {stu2,stu3};
//        SportStudent[] jump = {stu1,stu4,stu5};

        Set<SportStudent>res = new HashSet<>();
        Set<SportStudent>run = new HashSet<>(Arrays.asList(stu1,stu2,stu3,stu4));
        Set<SportStudent>jump = new HashSet<>(Arrays.asList(stu1,stu2,stu3));


        //并集
        res.addAll(run);
        res.addAll(jump);
        System.out.println("参加的同学有："+res);


        //交集
        res.addAll(run);
        res.retainAll(jump);
        System.out.println("两项都参加的同学有："+res);


        //差集
        res.addAll(run);
        res.removeAll(jump);
        System.out.println("只参加跳绳的同学：" + res);
    }
}
